package com.hgw.demo02_LisPrinciple;

/**
 * Data time:2021/12/10 23:31
 * StudentID:2019112118
 * Author:hgw
 * Description:
 */
public class Liskovbefore {

    public static void main(String[] args) {
        A a = new A();
        System.out.println("1+2=" + a.func1(1, 2));
        B b = new B();
        System.out.println("1+2=" + b.func1(1, 2));
    }
}
// A类
class A {
    // 返回两个数相加
    public int func1(int num1, int num2) {
        return num1 + num2;
    }
}

// B类 继承了A类
class B extends A {
    // 这里不小心改写了A类的func1方法
    public int func1(int num1, int num2) {
        return num1 + num2 + 1;
    }
    // 返回两个数相加
    public int func2(int num1, int num2) {
        return func1(num1, num2);
    }
}